﻿using HR60_PanelSoft.Model;
using HR60_PanelSoft.Tools;
using HR60_PanelSoft.NetWork.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HR60_PanelSoft.NetWork.Sender
{
    class Sender_010C : BaseSender
    {

        public Sender_010C(byte panelNo, Panel panel)
        {
            byte[] data = new byte[2];







            data[0] = (byte)getCount(panel.pages,0);
            data[1] = (byte)getCount(panel.scenePages,1);

            this.package = Package.getPackage(0x01, 0x0C, panelNo, 0x01, data);



        }

        private int getCount(List<PanelPage> pages,int type)
        {
            int count = 0;
            foreach (PanelPage pp in pages)
            {
                foreach (PanelButton pb in pp.buttons)
                {
                    if (type == 0)
                    {
                        if (!StringUils.isBlack(pb.mappingDevice) || !StringUils.isBlack(pb.mappingScene))
                        {
                            count++;
                        }

                    }
                    else
                    {
                        if (!StringUils.isBlack(pb.mappingScene))
                        {
                            count++;
                        }
                    }

                   
                }

            }
            return count;
        }
    }
}
